// 这里没有解决跨域问题，但可以通过后解决跨域问题在后端的Controller层使用@CrossOrigin
import request from '../utils/request'

export function getFactoryList(currentPage, pageSize) {
  return request({
    url: '/factory/list',
    method: 'get',
    params: {
      currentPage,
      pageSize,
    }
  })
}

export function getFactory(factoryId) {
  return request({
    url: '/factory/' + factoryId,
    method: 'get',
  })
}

export function addFactory(data) {
  return request({
    url: '/factory',
    method: 'post',
    data: {
      ...data
    }
  })
}

export function deleteFactory(factoryIds) {
  return request({
    url: '/factory/' + factoryIds,
    method: 'delete',
  })
}

export function findFactory(flag, data, currentPage, pageSize) {   //类型、数据、用户
    return request({
      url: '/factory/find',
      method: 'get',
      params: {
        flag,
        data,
        currentPage,
        pageSize
      }
    })
}

export function editFactory(data) {
  return request({
    url: '/factory',
    method: 'put',
    data: {
      ...data
    }
  })
}

export function  exportExcel(){
  return request({
    url: '/factory/export',
    method: 'get',
    responseType: 'blob'
  })
}
